import { createReducer } from '@reduxjs/toolkit';

import {
    increment,
    decrement
} from './actions';

interface CounterState {
    value: number
}

const initialState: CounterState = { value: 0 }

const counterReducer = createReducer(initialState, (builder) => {
    builder
    .addCase(increment, (state, action) => {
        state.value++
    })
    .addCase(decrement, (state, action) => {
        state.value--
    })
})

export default counterReducer